package com.example.swimmingpool.controller.question;

import com.example.swimmingpool.entity.question.Question;
import com.example.swimmingpool.response.CommonResponse;
import com.example.swimmingpool.service.question.QuestionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/question")
public class QuestionController {
    @Resource
    private QuestionService questionService;

    @PostMapping("/add")
    public CommonResponse<Boolean> add(@RequestBody Question question) {
        return CommonResponse.success(questionService.addQuestion(question));

    }

    @PostMapping("/remove")
    public CommonResponse<Boolean> remove(@RequestBody Question question) {
        return CommonResponse.success(questionService.removeQuestion(question));

    }

    @PostMapping("/update")
    public CommonResponse<Boolean> update(@RequestBody Question question) {
        return CommonResponse.success(questionService.updateQuestion(question));
    }

    @PostMapping("/list")
    public CommonResponse<List<Question>> list() {
        return CommonResponse.success(questionService.getQuestions());

    }

}
